from App.models.cinema_admin.cinema_user_model import CinemaUser

# 登录的时候判断有没有这个用户，用于验证的一个封装
def get_cinema_user(user_ident):        # 一个标识，可以是id、用户名或手机号
    if not user_ident:
        return None

    user = CinemaUser.query.filter(CinemaUser.id == user_ident).first()        # 根据id找到
    # user = MovieUser.query.get(user_ident)        # 根据id找到
    if user:
        return user

    user = CinemaUser.query.filter(CinemaUser.phone == user_ident).first()
    if user:
        return user

    user = CinemaUser.query.filter(CinemaUser.username == user_ident).first()
    if user:
        return user

    return None
